package top.itczw;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import top.itczw.beetl.dao.DepartmentDao;
import top.itczw.beetl.dao.UserDao;
import top.itczw.beetl.entity.Department;
import top.itczw.beetl.entity.User;
import top.itczw.beetl.service.RoleService;
import top.itczw.beetl.service.UserService;

import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = BeetlRunApplication.class)
public class BeetlsqlApplicationDemo {

    @Autowired
    private UserService userService;


    @Autowired
    private RoleService roleService;

    @Autowired
    private DepartmentDao departmentDao;

    @Autowired
    private UserDao userDao;

    @Test
    @Transactional
    public void contextLoads() {
        User user = userService.findById(3);
        System.out.println(user.toString());
//        User user = new User();
//        user.setAge(13);
//        user.setName("事务");
//        user.setCreateDate(new Date());
//        userService.insert(user,true);
//        int i = 1 / 0;
    }

    @Test
    public void adminTest(){
        List<Department> all = departmentDao.all();
        System.out.println(all.toString());
    }

    @Test
    public void all(){
        List<User> userList = userDao.all(1, 10);
        System.out.println(userList.toString());
    }

}
